Safe area modifiers in Scripting allow you to adjust layout behavior relative to the system-defined safe areas, such as the areas around notches, toolbars, or the on-screen keyboard.
safeAreaPadding
Adds custom padding inside the safe area of a view. This modifier adjusts the visible content region by extending or inseting from the edges defined by the system’s safe area (e.g., accounting for the notch, home indicator, or rounded corners).
This modifier gives fine-grained control over how much padding should be added inside the safe area for specific edges or directions. You can either apply:
true
number
This modifier is particularly useful when you want the view to respect or override the system safe area while maintaining proper layout spacing.
true
: Applies default system padding on all safe area edgesnumber
: Applies the specified number of points as uniform padding on all edgesobject
: Specifies padding per edge or directionhorizontal
: Padding for both leading
and trailing
edgesvertical
: Padding for both top
and bottom
edgesleading
, trailing
, top
, bottom
: Individual edge-specific paddingnumber
or true
to apply system default padding for that edgeApplies system default padding on all safe area edges.
Adds 20 points of padding at the top, system default padding at the bottom, and 12 points on both horizontal edges.
safeAreaInset
Inserts a custom view into the safe area edge of another view.
top
, bottom
, leading
, or trailing
.top
and bottom
): "leading"
, "center"
, "trailing"
leading
and trailing
): "top"
, "center"
, "bottom"
spacing
is optional. If omitted, a default system spacing will be applied.sapcing
typo in the leading
/trailing
definition should be interpreted as spacing
.ignoresSafeArea
Expands a view’s content to extend into one or more safe area regions.
This will ignore all safe area regions on all edges.
regions
(optional)Value | Description |
---|---|
"all" |
Ignores all regions (default) |
"container" |
Ignores container padding (e.g., nav/tab bars) |
"keyboard" |
Ignores the software keyboard area |
edges
(optional)Value | Description |
---|---|
"top" |
Ignores the top safe area |
"bottom" |
Ignores the bottom safe area |
"leading" |
Ignores the leading (left) safe area |
"trailing" |
Ignores the trailing (right) safe area |
"vertical" |
Ignores top + bottom |
"horizontal" |
Ignores leading + trailing |
"all" |
Ignores all edges (default if omitted) |